<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* Start of file customers.php */
/* Location: ./billing-ar/models/customers.php */
class Customers extends CI_Model {
    
	function __construct(){
        parent::__construct(); /** Call the Model constructor */
    }
    
    function getCustomerData($all=''){
        $this->db->order_by('Perusahaan','ASC');
		$Q=$this->db->get('customer');
		if ($Q->num_rows() > 0):
			foreach ($Q->result_array() as $row):
                if(!empty($all))
                    $data['All']      = 'All';    
				$data[$row['CustID']] = $row['Perusahaan'];
			endforeach;
		endif;
        $Q->free_result();
		return $data;   
	}
    
    function getCustomer($id=''){
        $this->db->select('CustID,Perusahaan,MataAnggaran');
        if($id)
            $this->db->where('CustID',$id);
        $Q = $this->db->get('customer',1);
        return $Q->row_array();    
    }
    
    function getAllCustomer($group='',$area=''){
        if($group)
            $this->db->select('DISTINCT CustomerGroup',FALSE);
        if($area)
            $this->db->where('CustomerGroup',$area);  
        $Q   = $this->db->get('customer');
        return $Q->result_array();
    }
}    